using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName ="RoomNodeGraph",menuName ="ScriptableObjects/Dunngen/RoomNodeGraph")]
public class RoomNodeGraphSO : ScriptableObject
{
    [HideInInspector] public List<RoomNodeSO> roomNodeList = new List<RoomNodeSO>();
    [HideInInspector] public RoomTypeList roomTypeList;
    [HideInInspector] public Dictionary<string, RoomNodeSO> roomNodeDictionary = new Dictionary<string, RoomNodeSO>();


    private void LoadDictionary()
    {
        roomNodeDictionary.Clear();
        foreach(RoomNodeSO room in roomNodeList)
        {
            roomNodeDictionary[room.id] = room;
        }
    }


#if UNITY_EDITOR
    [HideInInspector] public RoomNodeSO roomNodeFrom = null;
    [HideInInspector] public Vector2 LineEndPos;
    public void setLinePos(RoomNodeSO roomNodeFrom, Vector2 end)
    {
        this.roomNodeFrom = roomNodeFrom;
        LineEndPos = end;
    }

    public void OnValidate()
    {
        LoadDictionary();
    }
 
    public RoomNodeSO GetRoomNode(string roomNodeID)
    {
        if (roomNodeDictionary.TryGetValue(roomNodeID, out RoomNodeSO roomNode))
        {
            return roomNode;
        }
        else return null;   
    }



#endif

}
